<?php

/**
 * LEAGUEMan
 * 
 * Copyright (C) 2007 Marko Bischof
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

require_once $mainframe->getPath("class", "com_leagueman");

$p = $params->get("project", 0);

$tm = intval(mosGetParam($_GET, "tm", 0));
if ($tm) {
	
	$teammap = LM::getLMTable("Teammap");
	$teammap->load($tm);
	$t       = $teammap->teammap_team;
}

$project	= LM::getLMTable("Project");

if($project->load($p)){

	$mode = intval(mosGetParam($_REQUEST, 'mode', 0));
	
	$tc = new Tableconfig();
	$tc->show_cnt_matches   = $params->get("show_cnt_matches");
	$tc->show_cnt_v         = $params->get("show_cnt_v");
	$tc->show_cnt_v1        = $params->get("show_cnt_v1");
	$tc->show_cnt_v2        = $params->get("show_cnt_v2");
	$tc->show_cnt_t         = $params->get("show_cnt_t");
	$tc->show_cnt_d         = $params->get("show_cnt_d");
	$tc->show_cnt_d1        = $params->get("show_cnt_d1");
	$tc->show_cnt_d2        = $params->get("show_cnt_d2");
	$tc->show_results       = $params->get("show_results");
	$tc->show_diff          = $params->get("show_diff");
	$tc->show_points        = $params->get("show_points");
	$tc->last_ranking       = $params->get("last_ranking");
	$tc->link_teams         = $params->get("link_teams");

	if($tm){
		$tc->fav_team       = $t;
	} else {
		$tc->fav_team       = $params->get("fav_team");
	}
    
	$tc->shortnames         = $params->get("shortnames");
	$tc->delta              = $params->get("delta");
	
	$tc->itemid             = $params->get("Itemid");
	$tc->mode               = $mode;
	$tc->limit_from         = $project->getMinRound();
	$tc->limit_to           = $project->getMaxRound();
	$tc->group              = "";

	$template = LM::getTemplate();
	$template->loadFilter("mambots");

	$html = $template->splugin("leagueman_show_leaguetable2", $project, $tc);
	echo $template->applyFilters($html);
}